import type {
  HomeSubject,
  HomeSubjectPageParams,
  HomeSubjectParams,
  HomeSubjectUpdateSortParams,
  HomeSubjectUpdateStatusParams,
} from '@/models/homeSubject'
import type { CommonResult, CommonPage } from '@/models/request'
import request, { ContentTypeEnum } from '@/utils/request'
export function fetchList(params: HomeSubjectPageParams) {
  return request<CommonPage<HomeSubject>>({
    url: '/home/recommendSubject/list',
    method: 'get',
    params: params,
  })
}

export function updateRecommendStatus(data: HomeSubjectUpdateStatusParams) {
  return request<CommonResult>({
    url: '/home/recommendSubject/update/recommendStatus',
    method: 'post',
    data: data,
  })
}

export function deleteHomeSubject(data: { ids: string }) {
  return request<CommonResult>({
    url: '/home/recommendSubject/delete',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': ContentTypeEnum.form,
    },
  })
}

export function createHomeSubject(data: HomeSubjectParams[]) {
  return request<CommonResult>({
    url: '/home/recommendSubject/create',
    method: 'post',
    data: data,
  })
}

export function updateHomeSubjectSort(params: HomeSubjectUpdateSortParams) {
  return request<CommonResult>({
    url: '/home/recommendSubject/update/sort/' + params.id,
    method: 'post',
    params: params,
  })
}
